package org.jeecg.common.util.wx;

import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang3.StringUtils;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public enum WxMsgTypeEnum {

    TEXTMSG("text","文本消息"),
    IMGMSG("image","图片消息"),
    VOICEMSG("voice","语音消息"),
    VIDEOMSG("video","视频消息"),
    SHORTVIDEOMSG("shortvideo","小视频消息"),
    LOCATIONMSG("location","地理位置消息"),
    LINKMSG("link","链接消息"),
    EVENT("event","事件推送");

    @Getter
    @Setter
    private String value;

    @Getter
    @Setter
    private String desc;

    WxMsgTypeEnum(String value, String desc){
        this.value = value;
        this.desc = desc;
    }

    public static WxMsgTypeEnum getByValue(String value){
        List<WxMsgTypeEnum> list = Arrays.stream(WxMsgTypeEnum.values()).filter(o-> StringUtils.equals(o.getValue(),value)).limit(1).collect(Collectors.toList());
        if(list.size() > 0){
            return list.get(0);
        }
        return null;
    }
}
